/**
 * Created by Laggo on 11/5/15.
 */
app.directive("cdschoselinecustom", ['lineCustomService', function (lineCustomService) {
    return {
        restrict: 'E',
        templateUrl: 'www/html/directive/choseLineCustom.html',
        replace: true,
        transclude: true,
        scope:{
            'customerid':'=',
            'customername':'='
        },
        link: function (scope, ele, attr) {
            //初始参数
            scope.parm = {
                currentPage:1,
                pageSize:10,
                area:'',
                customerName_like:'',
            }
            //查询接口
            function query(data){
                lineCustomService.list(data).then(function (e) {
                    scope.list = e.resultData;
                    scope.parm.totalSize = e.totalSize
                })
            }
            //第一次加载数据
            query(scope.parm);

            //搜索功能
            scope.search = function () {
                query(scope.parm);
            }
            //分页功能
            scope.pageChanged = function(e){
                scope.parm.currentPage = e;
                query(scope.parm);
            }
            //选择客户
            scope.chose=function(id,name){
                scope.customerid = id;
                scope.customername = name;
            }
        },
    }
}]);
